class LookuplistsController < ApplicationController
  # GET /lookuplists
  # GET /lookuplists.xml
  layout "admin",:only=>:index
  before_filter :admin?
  def index
    @lookuplists = Lookuplist.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @lookuplists }
    end
  end

  # GET /lookuplists/1
  # GET /lookuplists/1.xml
  def show
    @lookuplist = Lookuplist.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @lookuplist }
    end
  end

  # GET /lookuplists/new
  # GET /lookuplists/new.xml
  def new
    @lookuplist = Lookuplist.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @lookuplist }
    end
  end

  # GET /lookuplists/1/edit
  def edit
    @lookuplist = Lookuplist.find(params[:id])
  end

  # POST /lookuplists
  # POST /lookuplists.xml
  def create
    @lookuplist = Lookuplist.new(params[:lookuplist])

    respond_to do |format|
      if @lookuplist.save
        flash[:notice] = 'Lookuplist was successfully created.'
        format.html { redirect_to(@lookuplist) }
        format.js {render :partial=>"lookups",:object=>Lookuplist.all}
        format.xml  { render :xml => @lookuplist, :status => :created, :location => @lookuplist }
      else
        format.html { render :action => "new" }
        format.js { render :action => "new" }
        format.xml  { render :xml => @lookuplist.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /lookuplists/1
  # PUT /lookuplists/1.xml
  def update
    @lookuplist = Lookuplist.find(params[:id])

    respond_to do |format|
      if @lookuplist.update_attributes(params[:lookuplist])
        flash[:notice] = 'Lookuplist was successfully updated.'
        format.html { redirect_to(@lookuplist) }
        format.js {render :partial=>"lookups",:object=>Lookuplist.all}
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.js {render :action => "edit"}
        format.xml  { render :xml => @lookuplist.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /lookuplists/1
  # DELETE /lookuplists/1.xml
  def destroy
    @lookuplist = Lookuplist.find(params[:id])
    @lookuplist.destroy

    respond_to do |format|
      format.html { redirect_to(lookuplists_url) }
      format.js {render :partial=>"lookups",:object=>Lookuplist.all}
      format.xml  { head :ok }
    end
  end
end
